@echo off
echo === 启动众筹项目 ===

:: 启动后端
echo 启动后端服务...
cd backend
start /B cmd /c "npm install && npm start"
cd ..

:: 等待后端启动
timeout /t 3 /nobreak > nul

:: 启动前端
echo 启动前端服务...
cd front
start /B cmd /c "npm install && npm run serve"
cd ..

:: 等待前端启动
timeout /t 3 /nobreak > nul

:: 启动区块链节点
echo 启动本地Hardhat节点...
cd my-hardhat-project
start /B cmd /c "npm install && npx hardhat node"
cd ..

:: 等待节点启动
timeout /t 5 /nobreak > nul

:: 部署合约
echo 部署智能合约...
cd my-hardhat-project
npx hardhat run scripts/deploy.js --network localhost
cd ..

echo === 所有服务已启动 ===
echo 后端服务: http://localhost:4000
echo 前端服务: http://localhost:8080
echo 本地区块链节点: http://localhost:8545
echo.
echo 按任意键停止所有服务
pause > nul
taskkill /f /im node.exe
